﻿@model IList<Tuple<ForumDto, IList<ForumPostDto>>>
@functions {
    MvcHtmlString GetCommentsCountBlock(ForumPostDto post)
    {
        if (post.NumberOfReplies == 0)
        {
            return new MvcHtmlString("");
        }

        return new MvcHtmlString("<span>(" + post.NumberOfReplies + ")</span>");
    }
}
<div class="inform-area">

	<div class="inform-area-head">
		<h2><a href="@Url.Action("Index", "Forum")">@Resources.EnetaMvc.Forum</a></h2>
	</div>

	<div class="inform-area-box">
		<div class="news-area inner">
			<div class="blog-area">
                @for(var i = 0; i < Math.Min(Model.Count, 2); i++)
                {
                    var blogBoxAdditionalClass = "";
                    var tuple = Model[i];
                    var forum = tuple.Item1;
                    var posts = tuple.Item2;
                    
                    if (i == 0)
                    {
                        blogBoxAdditionalClass = "first";
                    }
				    <div class="blog-box @blogBoxAdditionalClass">
					    <h4><a href="@Url.Action("Forum", "Forums", new { id = forum.Id })">@forum.Name</a></h4>
					    <ul class="list">
                            @for(var j = 0; j < Math.Min(posts.Count, 3); j++)
                            {
                                var post = posts[j];
                                if(j == 0)
                                {
						            <li>
							            <h5><a href="@Url.Action("Topic", "Forums", new { id = post.Id })">@post.Title @GetCommentsCountBlock(post)</a></h5>
							            <p>@post.GetTextAbstract()</p>
							            <span>@post.Created.ToShortDateString() @post.Created.ToShortTimeString()  |  @post.CreatedByUserName</span> 
						            </li>
                                }
                                else 
                                {                                    
						            <li><a href="@Url.Action("Topic", "Forums", new { id = post.Id })">@post.Title @GetCommentsCountBlock(post)</a></li>
                                }
                            }
					    </ul>
				    </div>
                }
			</div>

			<div class="side-area">
                @if(Model.Count >= 3)
                {
                    var forum = Model[2].Item1;
                    var posts = Model[2].Item2;
                        
					<h4><a href="@Url.Action("Forum", "Forums", new { id = forum.Id })">@forum.Name</a></h4>
					<ul class="list">
                        @for(var i = 0; i < Math.Min(posts.Count, 3); i++)
                        {
                            var post = posts[i];
                            if(i == 0)
                            {
						        <li>
							        <h5><a href="@Url.Action("Topic", "Forums", new { id = post.Id })">@post.Title @GetCommentsCountBlock(post)</a></h5>
							        <p>@post.GetTextAbstract()</p>
							        <span>@post.Created.ToShortDateString() @post.Created.ToShortTimeString()  |  @post.CreatedByUserName</span> 
						        </li>
                            }
                            else 
                            {                                    
						        <li><a href="@Url.Action("Topic", "Forums", new { id = post.Id })">@post.Title @GetCommentsCountBlock(post)</li>
                            }
                        }
					</ul>
                }
			</div>
		</div>

		<div class="tools">
			@*<div class="slide-box">
				<div class="slide-box-center">
					<div class="slide-box-bottom"> <a class="close" href="#">close</a>
						<div>
							<p>Kuulsus ja auhinnad! <a href="#">Logi sisse</a> ja tule foorumi moderaatoriks.</p>
						</div>
					</div>
				</div>
			</div>*@
			<a class="more" href="@Url.Action("Index","Forum")">@Resources.EnetaMvc.AllTopics</a> </div>
	</div>
	<span class="inform-area-btm">&nbsp;</span> 
</div>